<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
    <title>问题列表</title>
</head>
<body>
<%@ include file="/WEB-INF/jsp/nav.jsp" %>
<div id="mainDiv" class="container" style="margin-top: 35px;">
        <style>
            form lable{
                margin-right: 50px;
            }
            .panel-body span{
                margin-right: 30px;
            }
        </style>
        <script type="text/javascript">
        	$(function(){
        		$("[name='condition']").change(function(){
        			location.href='?condition='+this.value;
        		});
        	});
        </script>
        
        <form action="<%=ctxPath%>/question/list.do" method="post" id="form">
            <input type="hidden" id="curr" name="pageNum" />
            <label class="checkbox-inline">
                <input type="radio" name="condition" value="allUnresolved" <c:if test="${condition==\"allUnresolved\"}">checked="checked"</c:if>/>解决中
            </label>
            <label class="checkbox-inline">
                <input type="radio" name="condition" value="allResolved" <c:if test="${condition==\"allResolved\"}">checked="checked"</c:if>/>已解决
            </label>
            <label class="checkbox-inline">
                <input type="radio" name="condition" value="myAsked" <c:if test="${condition==\"myAsked\"}">checked="checked"</c:if>/>我提问的问题
            </label>
            <label class="checkbox-inline">
                <input type="radio" name="condition" value="myAnswered" <c:if test="${condition==\"myAnswered\"}">checked="checked"</c:if>/>我回复的问题
            </label>
        </form>
        
        <div class="panel-group" style="margin-top: 20px;">
            <c:forEach items="${pageInfo!=null?pageInfo.list:questions}" var="question">
                <div class="panel panel-default"> 
                    <div class="panel-body"> 
                            <a href="<%=ctxPath %>/question/detail.do?id=${question.id}" target="_blank"> 
                                <span>${question.username }</span>
                                <span><fmt:formatDate value="${question.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></span>
                                <span>${question.courseInfo}</span>
                                <c:if test="${question.isResolved }"><span class="label label-success">已解决</span></c:if>
                            </a> 
                    </div> 
                </div>
            </c:forEach>
                <!-- 作为分页栏容器 -->
            <c:if test="${pageInfo!=null and pageInfo.pages>1 }">
			<div id="pagination"></div>
				<script type="text/javascript">
				    <!-- 创建分页栏 -->
				    laypage({
				        cont:"pagination",//分页栏id
				        pages:${pageInfo.pages},//总页数
				        curr:${pageInfo.pageNum},//当前页
				        jump:function(options,first){
				            if(!first){
				            	document.getElementById("curr").value=options.curr;
				                document.getElementById("form").submit();
				            }
				        }
				    });
				</script>
			</c:if>
        </div>
    </div>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
</body>
</html>